package org.opens.mybatisplus.pojo.dto;

import com.google.common.collect.ComparisonChain;
import lombok.Data;
import org.apache.ibatis.type.Alias;

import java.util.Date;

/**
 * 说明:
 *      1. @Alias(value = "myBatisPerson")注解用于给当前pojo起别名, 这个别名在mapper.xml文件中指定resultMap和resultType时可用.
 */
@Alias(value = "myBatisPerson")
public class MyBatisPerson implements Comparable<MyBatisPerson> {

    /**
     * 用户id
     */
    private Integer id;

    /**
     * 用户姓名, 该字段用来验证jpa是否会自动处理驼峰-下划线命名规则.
     */
    private String nameValue;

    /**
     * 用户年龄
     */
    private Integer old;

    /**
     * 地址
     */
    private String ekAddress;

    public MyBatisPerson() {
    }

    public MyBatisPerson(Integer id, String nameValue, Integer old, String ekAddress) {
        this.id = id;
        this.nameValue = nameValue;
        this.old = old;
        this.ekAddress = ekAddress;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNameValue() {
        return nameValue;
    }

    public void setNameValue(String nameValue) {
        this.nameValue = nameValue;
    }

    public Integer getOld() {
        return old;
    }

    public void setOld(Integer old) {
        this.old = old;
    }

    public String getEkAddress() {
        return ekAddress;
    }

    public void setEkAddress(String ekAddress) {
        this.ekAddress = ekAddress;
    }

    @Override
    public int compareTo(MyBatisPerson o) {
        return ComparisonChain.start()
                .compare(id, o.getId())
                .compare(nameValue, o.getNameValue())
                .compare(old, o.getOld())
                .compare(ekAddress, o.getEkAddress())
                .result();
    }

    @Override
    public String toString() {
        return "MyBatisPerson{" +
                "id=" + id +
                ", nameValue='" + nameValue + '\'' +
                ", old=" + old +
                ", ekAddress='" + ekAddress + '\'' +
                '}';
    }

    @Data
    public static class Count {

        private Integer count;

    }

    @Data
    public static class PageParams {

        private Integer id;

        private String name;

        private Date startDate;

    }

    public static class Count2 extends BaseCount {

        public static Count2 getInstance() {
            Count2 count2 = new Count2();

            count2.setTotal(0);
            count2.setHitCount(0);
            count2.setAvg(0D);
            count2.setSum(0D);

            return count2;
        }

    }

}

